import React from 'react';
import styles from './WechatLogin.css';
// import Dialog from 'material-ui/Dialog';

import { Modal} from 'antd';
import 'antd/dist/antd.css'
import classnames from 'classnames';
import { connect } from 'react-redux';

class WechatLogin extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            toggle:true,
        };
        // console.log(window.location.href)
    }

    render() {
        // console.log(this);
        const open = this.props.open;
        const isLogin = this.state.toggle;
        const toggleClass = isLogin ? 'loginBg' : 'regBg';

        return (
          <Modal
            visible={open}
            onCancel={this.props.handleClose}
            footer={null}
            closable
          >
                <div className={styles.wechatLoginSec}>
                    <div className={classnames(styles.imageSec, styles[toggleClass])}></div>
                    <div className={styles.inputSec}>
                        <iframe  className={styles.nlogin_iframe} frameBorder="0"  sandbox="allow-scripts allow-same-origin allow-top-navigation" scrolling="no"
                                 src={this.props.user =='teacher' ?
                                   "https://open.weixin.qq.com/connect/qrconnect?appid=wxd7be34e0f2844079&redirect_uri=http%3a%2f%2fv.huanqiushuju.com%2f&response_type=code&scope=snsapi_login&state=1#wechat_redirect"
                                    :
                                   "https://open.weixin.qq.com/connect/qrconnect?appid=wxd7be34e0f2844079&redirect_uri=http%3a%2f%2fv.huanqiushuju.com%2f&response_type=code&scope=snsapi_login&state=2#wechat_redirect"
                                 }></iframe>
                    </div>
                </div>
          </Modal>
        )
    }
}


export default connect()(WechatLogin);
